<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="专题名称">
              <a-input placeholder="请输入专题名称" v-model="queryParam.subjectName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="专题编号">
              <a-input placeholder="请输入专题编号" v-model="queryParam.subjectCode"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="10" :lg="11" :md="12" :sm="24">
              <a-form-item label="创建时间">
                <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.createTime_begin"></j-date>
                <span class="query-group-split-cust"></span>
                <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.createTime_end"></j-date>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="创建人">
                <a-input placeholder="请输入创建人" v-model="queryParam.createBy"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="专题描述">
                <a-input placeholder="请输入专题描述" v-model="queryParam.subjectDes"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="确认人">
                <a-input placeholder="请输入确认人" v-model="queryParam.confirmorId"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->


    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type: multiple ? 'checkbox':'radio'}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="subjectName" slot-scope="text, record">
          <a @click="handleDetail(record)">{{text}}</a>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
      </a-table>
    </div>

    <hf-pm-project-subjects-modal ref="modalForm" @ok="modalFormOk"></hf-pm-project-subjects-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HfPmProjectSubjectsModal from './HfPmProjectSubjectsModal'

  export default {
    name: 'HfPmProjectSubjectsSelectList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      HfPmProjectSubjectsModal
    },
    props: {
      multiple: {
        type: Boolean,
        default: true
      }
    },
    data() {
      return {
        description: '专题列表管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '专题编号',
            align: 'center',
            dataIndex: 'subjectCode',
            scopedSlots: { customRender: 'subjectName' }
          },
          {
            title: '专题名称',
            align: 'center',
            dataIndex: 'subjectName'
          },
          {
            title: '项目简称',
            align: 'center',
            dataIndex: 'projectName'
          },
          {
            title: '预计开始时间',
            align: 'center',
            dataIndex: 'playStartTime',
            customRender: function(text) {
              return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
            }
          },
          {
            title: '预计结束时间',
            align: 'center',
            dataIndex: 'playEndTime',
            customRender: function(text) {
              return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
            }
          },
          {
            title: '专题描述',
            align: 'center',
            dataIndex: 'subjectDes'
          },
          {
            title: '预估人天',
            align: 'center',
            dataIndex: 'estimateWorkday'
          },
          {
            title: '实际人天',
            align: 'center',
            dataIndex: 'realityWorkday'
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'subjectState'
          },
          {
            title: '确认人',
            align: 'center',
            dataIndex: 'confirmorName'
          },
          {
            title: '备注',
            align: 'center',
            dataIndex: 'remarks'
          }
        ],
        url: {
          list: '/pm/hfPmProjectSubjects/list'
        },
        dictOptions: {},
        superFieldList: []
      }
    },
    created() {
      this.getSuperFieldList()
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      initDictConfig() {
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>